-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: font picker #210
feat: font picker #210
Conversation
@laurelfulford could you take a look at this PR with two particular questions in mind?
|
@adekbadek before I get too far along on this PR I wanted to check if the approach runs afoul of #132? This PR creates a new sidebar panel for typography—should this be override-able in other ESP implementations, or should it be universal? |
The only potential issue with stretching the font list has more to do with the experience editing the newsletter than those receiving it. If we're relying strictly on system fonts, it means someone will have to have a font installed to see it -- and though this is fine for the emails (we'll have font stacks to make sure there are a few similar options to fall back on if they don't have the first font), if someone creating a newsletter doesn't have the font installed, it won't preview the right one for them. We could get around this with some education/expectation settings, though, maybe even wrangle some links to download the fonts if we do hear from any publishers. The benefits of stretching the list a bit -- and providing some more variety! -- could be worth the possible bit of friction. We could also just start with the short "guaranteed" list for now, and build on it after the feature is launched :)
Since we're just looking at applying these styles to the editor (vs the front-end of the site), I think it could be a good opportunity to experiment with CSS variables, to follow what's being used in Global Styles in Gutenberg. We'd just need a change whatever the variable values are, both on editor load (if they're editing an existing newsletter), and on the fly via JavaScript if they mess with the font picker. We're currently not using CSS Variables in the theme because they aren't supported by IE11. It seems unlikely that any publishers would be using IE11 to edit their site, but if it happens it would just mean that they would not see a change in the preview when they changed the fonts. |
In the end the font rendering depends on the email client, so I think this feature is universal. We should add a note though that it's not guaranteed that the font will be rendered as intended in some email clients. |
I pushed an update to switch the editor to use CSS variables for the header and body fonts. With those updates, you can switch the fonts by adding the following JavaScript to the console:
or
The defaults for the variables are both set to an Helvetica/Arial font stack, but when the fonts aren't set to the default, something like the above would need to fire on page load (for editing existing newsletters), and when a new font is selected. I've also updated the styles so the font changes shouldn't affect the placeholder text (like the "Posts Inserter" header, or blocks like the Image block before you've uploaded anything). |
1ceca16
to
b90f985
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In testing, the fonts change as expected, and when I edit a newsletter, save it, and return to the editor, the font selections are saved.
A couple things I noticed:
'System' as is isn't a font -- when I pick it, the preview switches the font to a serif font in the editor. I've normally seen that referring to a specific 'system font stack' that includes similar fonts for OSX, Windows, and Linux -- like -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
from here. (This is what the theme uses as the default header font). I'm not sure if it'd be better to update the option to load that stack, or remove it (and/or use it as the fallback list for the sans-serif fonts) since it kind of overlaps the other options that are there.
Also, a couple of the blocks -- buttons, image captions -- are picking up the body font in the editor, but not picking up any font in the actual email (there, they're using the original Ubuntu, Helvetica, Arial, sans-serif
default). I'm not sure which is actually correct -- it might just be that I have it wrong in the editor -- but wanted to confirm before I make any changes:
Lastly, something I know I have to fix: the links nested in h1-h6 (like the post titles) are picking up the body font in the editor, rather than the header font. They're displaying correctly in the email; I can push up a change for this shortly, but wanted to record the "why".
Jeff and I chatted about this and decided the email should be considered correct here, so I'll be following up shortly with an update to the editor to fix it there. |
Opted to simply remove |
Fixed in f212f98 |
For now we're offering only email-safe fonts as described by Mailchimp, so I would think there's no need for a warning. @adekbadek have you seen cases where these don't render in email clients? |
Resolved an issue where emails sent immediately after a font change do not reflect the change, in fe0e4b1. Set the default fonts to Arial/Georgia in 3dc85bd The PR should be ready for review again cc: @adekbadek @laurelfulford |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Works well, I just have two remarks.
{ | ||
value: null, | ||
label: __( 'Monospace', 'newspack-newsletters' ), | ||
disabled: true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are these three disabled option in the select? Also, two of them are not in the backend list of fonts.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Serif
, Sans Serif
and Monotype
are category groupings, not actual fonts. It's meant to match this screenshot, although without the indentation. Actually all three of these should be absent from the list of fonts—which was the one you did find?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
category groupings
SelectControl
does not support optgroup
:/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'Serif'
is on the PHP list
Whoops: 7bb8e8b
@adekbadek pointed out that the mockups call for |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
😎
3b13690
to
53cd2c2
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 LGTM!
# [1.1.0](v1.0.1...v1.1.0) (2020-06-09) ### Bug Fixes * prevent deduplication in layout picker preview ([4a5721e](4a5721e)), closes [#199](#199) * **posts-inserter:** prevent empty featured image rendering ([56a97c4](56a97c4)), closes [#201](#201) * resolve excerpt length issue ([d40f98a](d40f98a)) * situation that overwrote mc campaign id ([8ecf564](8ecf564)) * update editor block paddings ([#195](#195)) ([eb100b8](eb100b8)) * when trashing post allow mailchimp api call to fail silently ([7e2d9c4](7e2d9c4)) * when trashing post allow mailchimp api call to fail silently ([8257451](8257451)) ### Features * add layouts management ([#165](#165)) ([446674f](446674f)), closes [#31](#31) [#216](#216) * font picker ([#210](#210)) ([0234bf9](0234bf9))
🎉 This PR is included in version 1.1.0 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
All Submissions:
Changes proposed in this Pull Request:
Add font selection to the Newsletters plugin. Adds a Typography sidebar panel with
SelectControl
s for choosing body and header fonts. The options are all web-safe fonts, described in screenshots in #198. Selected fonts will immediately be used in the editor and in rendered emails.Note: the editor font switching uses CSS variables, which are not supported in IE11: https://caniuse.com/#feat=css-variables.
Closes #198
How to test the changes in this Pull Request:
Other information: